package com.learn.jdk.caseDemo;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author: lipan
 * @date: 2021/5/6 21:16
 */

public class FlatMapDemo {



      @Test
       public void test() throws Exception{

           String [] str=new String[]{"hello","world"};

           //hello --> new String[]{"h","e","l","l","o"}
          //world->new String[]{"w","o","r","l","d"}
          Stream<String[]> stream = Arrays.stream(str).map(s -> s.split(""));
          //把流中的每一个数组转为steam再合并
          Stream<String> newStrem= stream.flatMap(Arrays::stream);

          List<String> collect = newStrem.distinct().collect(Collectors.toList());




      }

}
